//
//  XQIdentityAccureCell.m
//  JoinPeso
//
//  Created by 小琦 on 2024/11/23.
//

#import "XQIdentityAccureCell.h"

@interface XQIdentityAccureCell()
@property (nonatomic,strong) UILabel *titleLb;
@property (nonatomic,strong) UIImageView *arrowImageView;
@end

@implementation XQIdentityAccureCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        [self makeUI];
        [self makeConstraints];
    }
    return self;
}

- (void)makeUI {
    [self.contentView addSubview:self.titleLb];
    [self.contentView addSubview:self.arrowImageView];
}

- (void)makeConstraints {
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@0);
        make.left.equalTo(@20);
        make.height.mas_equalTo(21);
        make.bottom.mas_equalTo(0);
    }];
    [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.titleLb);
        make.right.equalTo(@0);
    }];
}

#pragma mark - setter

- (void)setTitle:(NSString *)title {
    self.titleLb.text = title;
}

- (void)setIsLast:(BOOL)isLast {
    [self.titleLb mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(isLast ? 0 : -29);
    }];
}

#pragma mark - lazy

- (UILabel *)titleLb {
    if (!_titleLb) {
        _titleLb = [[UILabel alloc] init];
        _titleLb.textColor = kBlackTextColor;
        _titleLb.font = [UIFont boldSystemFontOfSize:15];
    }
    return _titleLb;
}

- (UIImageView *)arrowImageView {
    if (!_arrowImageView) {
        _arrowImageView = [[UIImageView alloc] init];
        _arrowImageView.image = [UIImage imageNamed:@"identity_arrow"];
        [_arrowImageView setUserInteractionEnabled:YES];
    }
    return _arrowImageView;
}

@end
